package com.example.moduleone.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import com.example.baselibrary.bean.PublicViewHolder;
import com.example.baselibrary.fragment.BaseFragment;
import com.example.baselibrary.util.BaseResourceUtil;
import com.example.baselibrary.util.router.RouterActivityIntentResourceKey;
import com.example.baselibrary.util.router.RouterTransferCenterUtil;
import com.example.moduleone.R;
import com.example.moduleone.activity.ModuleOneMainActivity;

/**
 * Created by sun.li on 2018/4/12.
 *
 * @author sun.li
 */

public class ModuleOneTestFragment extends BaseFragment{

    private ViewHolder viewHolder;

    @Override
    protected int initLayoutRes() {
        return R.layout.fragment_test_module_one;
    }

    @Override
    protected PublicViewHolder initViewHolderObject() {
        viewHolder = new ViewHolder();
        return viewHolder;
    }

    @Override
    protected void baseOnClick(int viewId) {
        if(BaseResourceUtil.whetherResourceIDSame(viewId,R.id.tv_fmmo_text)){
            Toast.makeText(getActivity(),viewHolder.tv_fmmo_text.getText(),Toast.LENGTH_SHORT).show();
        }else if(BaseResourceUtil.whetherResourceIDSame(viewId,R.id.tv_fmmo_text_1)){
            getActivity().finish();
        }else if(BaseResourceUtil.whetherResourceIDSame(viewId,R.id.tv_fmmo_text_2)){
            /* 测试路由功能，ModuleOne跳转ModuleTwo*/
            Intent intent = RouterTransferCenterUtil.getInstance().getRouterIntent(getActivity(),
                    RouterActivityIntentResourceKey.KEY_MODULE_TWO_ACTIVITY);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
            getActivity().startActivity(intent);
        }
    }

    @Override
    protected void initView(Bundle bundle) {
        super.initView(bundle);
        viewHolder.tv_fmmo_text_1.setText("退出ModuleOneTestFragment");
    }

    public class ViewHolder extends PublicViewHolder {
        TextView tv_fmmo_text;

        TextView tv_fmmo_text_1;

        TextView tv_fmmo_text_2;
    }
}
